package com.educatioin.manage.utils;

/**
 * Created by Zhangyin on 2018/4/6.
 * 微信API URL 构造工具类
 */
public class WeChatUriUtil {

    // 1.获取code的请求地址
    public static String GET_CODE = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s#wechat_redirect";
    // 替换字符串
    public static String getCode(String appId, String redirectUri,String scope, String codeState) {
        return String.format(GET_CODE,appId,redirectUri,scope, codeState);
    }

    // 2.获取Web_access_tokenhttps的请求地址
    public static String WEB_ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
    // 替换字符串
    public static String getWebAccess(String APPID, String SECRET,String CODE) {
        return String.format(WEB_ACCESS_TOKEN, APPID, SECRET,CODE);
    }

    // 3.拉取用户信息的请求地址
    public static String USER_MESSAGE = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN";
    // 替换字符串
    public static String getUserMessage(String access_token, String openid) {
        return String.format(USER_MESSAGE, access_token,openid);
    }

}
